#!/usr/bin/env python
# -*- coding: utf-8 -*-

from teamupshoppers import app
from flask import Flask, views, jsonify, render_template, request, session

from flask.ext.login import login_required
import uuid,logging,json

from main import Main
from login import Login
from login import Logout
from register import Register
from notice import Notice

app.secret_key = str( uuid.uuid1() )

app.add_url_rule('/',           view_func=Main.as_view('main'),         methods = ['GET'])        
app.add_url_rule('/login',      view_func=Login.as_view('login'),       methods = ['POST'])
app.add_url_rule('/logout',     view_func=Logout.as_view('logout'),     methods = ['GET','POST'])
app.add_url_rule('/register',   view_func=Register.as_view('register'), methods = ['POST'])

notice_view = Notice.as_view('notice')
app.add_url_rule('/notice/',    defaults={'notice_id': None}, view_func=notice_view, methods=['GET',])
app.add_url_rule('/notice/',    view_func=notice_view, methods=['POST',])
app.add_url_rule('/notice/<int:notice_id>', view_func=notice_view, methods=['GET', 'PUT', 'DELETE'])

notice_view = Notice.as_view('user')
app.add_url_rule('/user/',    defaults={'user_id': None}, view_func=notice_view, methods=['GET',])
app.add_url_rule('/user/',    view_func=notice_view, methods=['POST',])
app.add_url_rule('/user/<int:user_id>', view_func=notice_view, methods=['GET', 'PUT', 'DELETE'])
